Skip to content

Remove the RemoteFactory class from the python module#4059

Merged
nrwahl2 merged 16 commits into
ClusterLabs:mainfrom
clumens:no-remote-factory
May 4, 2026
Merged

Remove the RemoteFactory class from the python module#4059
nrwahl2 merged 16 commits into
ClusterLabs:mainfrom
clumens:no-remote-factory

Conversation

@clumens
Copy link
Copy Markdown
Contributor

@clumens clumens commented Feb 16, 2026

No description provided.

@clumens clumens requested a review from nrwahl2 February 16, 2026 21:16
Comment thread python/pacemaker/_cts/remote.py Outdated
from pacemaker._cts import logging


def convert2string(lines):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, it's unclear to me that this was actually useful in the
first place. We were logging the byte strings before converting them to
text.

Well... sort of. With verbose == 2, __call__() was logging stdout (as result) as UTF-8. But it was logging stderr (as errors) as bytes. As for AsyncCmd.run(), it was logging stdout and stderr as bytes, but then it was passing them to async_complete() as text.

I think what you're doing here is fine -- do everything as text. I'm just clarifying what was happening before, if I'm reading it correctly.

Comment thread python/pacemaker/_cts/remote.py Outdated
def __init__(self):
"""Create a new RemoteExec instance."""

# @TODO This should be an argument list that gets used with subprocess,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to do this now, but it looks pretty straightforward, even if tedious.

As an intermediate step, you could even use shlex.split() to split a command string into a list. Then you could pass it to subprocess.X. Not necessary now unless you want to.

Comment thread python/pacemaker/_cts/remote.py Outdated
Comment thread python/pacemaker/_cts/remote.py Outdated
Comment thread python/pacemaker/_cts/CTS.py Outdated
Comment thread python/pacemaker/_cts/CTS.py Outdated
Comment thread python/pacemaker/_cts/tests/cibsecret.py Outdated
clumens added 10 commits May 4, 2026 10:47
It's perfectly valid for PCMK__XA_LRMD_QUEUE_TIME to be zero.

This gets set in send_cmd_complete_notify by execd where it's defined by
the time the command started running minus the time it was enqueued.  If
the command never started running because it was canceled first, then
queue time can be negative.

This most often comes up in a handful of cts-exec regression tests.  I
don't think it's causing any actual problem, but assertions in log files
are always worth investigating and removing.

Fixes T1009
There's no need for these functions now that they're just pass throughs.

Ref T680
It's only ever True in one place, and I don't think I care about that.
We can just always log.

Ref T680
It defines some fairly common function names like "run" that I want to
use, so it makes sense to import the whole module and force us to do
"subprocess.popen" instead.
This is only ever used in one place.  It can just be an argument array
instead.  And while I'm at it, do what the TODO suggested and use
subprocess instead.

Ref T680
If we pass universal_newlines=True when we create a Popen object, the
resulting streams will be text instead of bytes (when we support python
>= 3.7, this is also called text=True).

Additionally, it's unclear to me that this was actually useful in the
first place.  We were logging the byte strings before converting them to
text.

Ref T680
This is also used in one place, so just define it as a private variable
in the class itself.  Note that it would really make a lot of sense to
also have this be a list of arguments, but in order to do that properly
we also need to change everywhere that runs a command to pass a list as
well.  That's a project for another day.

Ref T680
* It completely duplicates what the async_call method does.

* There's one caller in LogAudit that was using it totally incorrectly.
  verbose=0 doesn't matter because that argument was never getting
  passed to AsyncCmd, so it would log however it wanted regardless.
  And, rc would always be 0 because we don't wait around for the process
  to give us a valid return code so the error message would never be
  logged.

Ref T680
This doesn't really do anything interesting now.  It just returns the
singleton instance of RemoteExec, but I don't think there's much savings
to be had in doing this instead of just creating a new instance each
time.  It's not a very complicated class with lots of variables that
take time to set up.

This also allows us to get rid of all of the pylint not-callable pragmas
since that level of indirection has been removed.

Ref T680
@clumens clumens force-pushed the no-remote-factory branch from 786ad57 to 7d7968d Compare May 4, 2026 15:29
@clumens
Copy link
Copy Markdown
Contributor Author

clumens commented May 4, 2026

CI failure is unrelated, but probably still worth looking into.

Comment thread python/pacemaker/_cts/remote.py Outdated
clumens added 6 commits May 4, 2026 15:28
I don't know if there's any reason to use one over the other, but
personally I like the more explicit function name.

Ref T680
What we really care about here is whether or not one system can ssh into
another, so all we need to do is just try to ssh without all those extra
options.

Ref T680
In general, you definitely want to do host key checking and this
option is set to "ask" by default.  However, in CTS, this means that if
you haven't ssh'd between systems first and done host key checking (or
at least responded to the ssh prompt), it will stop and ask.  This
results in test case failures.

So add this argument to just skip the host key checking and prevent
those failures.  I think this is reasonable to do in CTS, but obviously
you wouldn't want to do this elsewhere.
This fixes a pylint warning regarding naming.
TCPKeepAlive=yes and ServerAliveCountMax=3 are ssh defaults, and appear
to have been ssh defaults for a very long time.  The only reason to
specify these would be if you had your ctslab machines configured
differently, which I don't expect anyone is doing.  Thus we can just
remove these.
@clumens clumens force-pushed the no-remote-factory branch from 7d7968d to 0fa0437 Compare May 4, 2026 19:30
@nrwahl2 nrwahl2 merged commit 47f72ff into ClusterLabs:main May 4, 2026
1 check failed
@clumens clumens deleted the no-remote-factory branch May 6, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants